<template>
  <div class="contact-us">
    <MenuBar></MenuBar>
    <div class="main w" v-if="pcOrWx">
      <ContactUsPhone></ContactUsPhone>
    </div>
    <div class="main w" v-else>
      <div class="title">
        <div class="left">
          联系我们
        </div>
        <ul class="right">
          <li @click="tabChange(1)">联系方式</li>
          <li @click="tabChange(2)">招聘信息</li>
          <li @click="tabChange(3)">在线留言</li>
        </ul>
      </div>
      <ContactInfo v-if="contactUsTab=='5-1'"></ContactInfo>
      <JoinUs v-if="contactUsTab=='5-2'"></JoinUs>
      <OnlineMessage v-if="contactUsTab=='5-3'"></OnlineMessage>
    </div>
    <Footers></Footers>
  </div>
</template>

<script>
  import {mapState, mapActions} from "vuex";
  import MenuBar from '../components/menuBar'
  import Footers from '../components/footers'
  import ContactInfo from '../components/contactUs/contactInfo'
  import JoinUs from '../components/contactUs/joinUs'
  import OnlineMessage from '../components/contactUs/onlineMessage'
  import ContactUsPhone from '../components/contactUs/contactUsPhone'


  export default {
    name: "contact-us",
    components: {
      MenuBar,
      Footers,
      ContactInfo,
      JoinUs,
      OnlineMessage,
      ContactUsPhone,
    },
    computed: {
      ...mapState({
        activeName: (state) => state.config.ACTIVE_NAME,
        pcOrWx: (state) => state.config.PC_OR_WX,
      })
    },
    data() {
      return {
        contactUsTab: '5-1',
      }
    },

    methods: {
      ...mapActions(['setActiveName',]),
      tabChange(val) {
        if (val == 1) {
          this.contactUsTab = '5-1';
          this.setActiveName(this.contactUsTab);
        } else if (val == 2) {
          this.contactUsTab = '5-2';
          this.setActiveName(this.contactUsTab);
        } else {
          this.contactUsTab = '5-3';
          this.setActiveName(this.contactUsTab);
        }
      },

      menuTab() {
        this.contactUsTab = this.$route.params.id;
      },
    },
    watch: {
      $route: 'menuTab',
    },

    mounted() {
      this.contactUsTab = this.$route.params.id;
      this.setActiveName(this.contactUsTab);
    },
  }
</script>

<style scoped lang="less">
  .contact-us {
    height: 100%;
    width: 100%;
    .main {
      background-color: #fff;
      .title {
        height: 80px;
        border-bottom: 1px solid #ccc;
        margin: 0 10px;
        box-sizing: border-box;
        display: flex;
        justify-content: space-between;
        align-items: center;
        .left {
          font-size: 18px;
          color: #4bb2df;
          padding-left: 36px;
        }
        .right {
          display: flex;
          li {
            padding-left: 50px;
            font-size: 12px;
            cursor: pointer;
          }
          li:before {
            content: '';
            display: inline-block;
            width: 4px;
            height: 4px;
            border-radius: 2px;
            background-color: #333;
            vertical-align: middle;
            margin-right: 5px;
          }
          li:hover,li:active{
            color:#4bb2df;
          }
          li:hover:before,li:active:before{
            background-color: #4bb2df;
          }
        }
      }
    }
  }

</style>
